package com.satan.juc.demo13;

import java.util.concurrent.locks.LockSupport;

/**
 * @Author: Demon
 * @Date: 2024/3/29 16:54
 * @Description:这个例子中，线程将会被阻塞直到指定的截止时间。
 **/
public class ParkUntilDemo {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            long deadline = System.currentTimeMillis() + 2000; // 2 seconds from now
            System.out.println("Thread is going to park until the deadline.");
            LockSupport.parkUntil(deadline);
            System.out.println("Thread is unparked or the deadline has passed.");
        });

        thread.start();
    }
}
